$(document).ready(function(){
	var waitCnt = 60;
	var t = undefined;
	var sever = "cdt"
	var money = $('.money1').val().replace(new RegExp(',',"gm"),'')
	var isIOS9 = $('.isIOS9').val();

	if(parseInt($('.isBound').val()) == 1){
		// if(isIOS9 == 1){
			location.href="/"+sever+"/pickUpMoney?access_token="+$('.access_token').val();
		// }
		// else{
			// location.href="/"+sever+"/downLoadLaiDian?state="+$('.state').val()+"&money="+money;
		// }
	}
	$.biginWait = function(){
		if(waitCnt == 60){
			waitCnt = waitCnt-1
			$('.getCheckCode').text(waitCnt);
			$('.getCheckCode').css('text-align','center').css('color','#000000');
		}
		else if (parseInt($('.getCheckCode').text()) > 1) {
			waitCnt = waitCnt-1;
			$('.getCheckCode').text(waitCnt);
		}
		else if(parseInt($('.getCheckCode').text()) == 1){
			waitCnt = 60;
			$('.getCheckCode').text("获取验证码").css('text-align','center').css('color','#000000');
			clearInterval(t);
			$('.getCheckCode').bind('click',function(){
				$.getJSON("/"+sever+"/authCodeGet?callback=?&mobile="+$('.phoneNumber').val(),function(json){
					if(json.result == 1){
						t = window.setInterval("$.biginWait()",1000);
						$('.getCheckCode').unbind("click");						
					}
					else{
						$.prompt('',1,'',json.msg,1,1,6000);	
					}
				});				
			});			
		}
	}

	$('.getCheckCode').bind('click',function(){
		if($('.phoneNumber').val().length != 11){
			$.prompt('',1,'',"请输入正确的电话号码",1,1,null);
			return false;
		}
		$.prompt('',1,'',"验证码已经发送",3,1,null);
		$.getJSON("/"+sever+"/authCodeGet?callback=?&mobile="+$('.phoneNumber').val(),function(json){
			if(json.result == 1){
				t = window.setInterval("$.biginWait()",1000);
				$('.getCheckCode').unbind("click");
			}
			else{
				$.prompt('',1,'',json.msg,1,1,6000);	
			}
		});
	});


	$('.check').bind('click',function(){
		if($('.checkingCode').val().length != 6){
			$.prompt('',1,'',"请输入正确的验证码",1,1,null);				
			return false;
		}		
		$('.check').attr("disabled","true");
		$.getJSON("/"+sever+"/authCodeBoundPhoneForWeiXin?callback=?&access_token="+$('.access_token').val()+"&mobile="+$('.phoneNumber').val()+'&authCode='+$('.checkingCode').val(),function(json){
			if(json.result == 1){
				// $('.prompt .message').append("<div style='padding-left:10%;width:90%;height:100%;text-align:left;'><span style='color:#000000;font-size:1.3em;'>请在来电APP中，<br/>使用绑定的手机号码登录！</span><br/><span style='font-size:0.9em;color:#919191'>登录后进行提现操作</span></div>");
				// $('.prompt').show();
				// $('.promptBg').show();
				// $('.prompt .ok').bind('click',function(){
					// if(isIOS9 == 1){
						location.href="/"+sever+"/pickUpMoney?access_token="+$('.access_token').val();
					// }
					// else{
						// location.href="/"+sever+"/downLoadLaiDian?state="+$('.state').val()+"&money="+money;
					// }					
				// })
			}
			else{
				$.prompt('',1,'',json.msg,1,1,6000);
			}
			$('.check').removeAttr("disabled");
		});
	})
});